<?php
header("content-type:text/html;charset=utf-8");
$sername="localhost";
$user="root";
$password="123123";
$dbname="xbs_bbs";
try{
    $conn=new PDO("mysql:host=$sername;dbname=$dbname;charset=utf8",$user,$password);
    echo "连接成功";
    $sql="select * from stus";
    $res=$conn->query($sql);
    if(!$res){
        echo $conn->errorInfo()[2];

    }
    foreach ($res->fetch() as $re) {
        var_dump($re);
    }

}catch (PDOException $e){
    echo $e->getMessage();

}
